package com.example.demo.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

@Configuration
public class RestConfig {

    @Bean
    public RestTemplate restTemplate() {
        SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
        //读取超时,默认无限制,单位：毫秒
        factory.setReadTimeout(6000 * 10);
        //连接超时，默认无限制，单位：毫秒
        factory.setConnectTimeout(6000 * 10);
        return new RestTemplate(factory);
    }

}
